<?php
	require_once "../classes/DB.php";
	$idFact = $_GET["idFact"];
	$imp = $_GET["imprimir"];
	$db=new DB();
       $query="Select d.nombre, d.rfc, d.direccion, d.cp, d.ciudad, d.estado, d.telefono, R.Fecha_Reservacion, R.Solicitud_Especial, R.Costo,f.fecha,f.descripcion,f.cantidad,r.saldo
			from datos_fiscales d, reservaciones r, facturas f
			where f.id_reservacion = r.id_reservacion
			and f.id_datos_fiscales = d.id_usuario
			and f.id_factura = '{$idFact}'
			order by f.fecha desc";
       $r=$db->query($query);
       if($db->total()>0){
               $row=$db->getRow();
               $ResValues= array("{$row[0]}","$row[1]","$row[2]","{$row[3]}","{$row[4]}","{$row[5]}","{$row[6]}","{$row[7]}","{$row[8]}","{$row[9]}","{$row[10]}","{$row[11]}","{$row[12]}","{$row[13]}");
       }
      $db->close();
?>

<table border="0" cellpadding="0" cellspacing="0" align="center" style="vertical-align:top;">	
    <tr>
		<th ALIGN = "CENTER" style="background-image:none; color:#000000;">
			<img border='0' src='../images/irenk.jpg' width="200" height="150">
		</th>
		<th ALIGN = "CENTER" style="background-image:none; color:#000000;">
			OPERADORA IRENK, S.A. DE C.V.<br>
			DIRECCION: xxXXXXXXXXXXXXXXXXXX<br>
			COL. XXXX<br>
			TEL: XXXXXX<br>
			www.xxxxx.com.mx<br>
			E-MAIL: XXX<br>
			RFC:XXXXXXXXXXXXX	<br>
			Fecha: <?php echo $ResValues[10];?>
		</th>
	</tr>
	<tr>
		<td colspan="2">
			<br>
			<table border"0" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td class="formtitle">Nombre:&nbsp;</td>
					<td colspan="3"><?php echo $ResValues[0];?></td>
				</tr>	
				<tr>
					<td class="formtitle">Direcci&oacute;n:&nbsp;</td>
					<td><?php echo $ResValues[2];?></td>
					<td class="formtitle">C.P.:&nbsp;</td>
					<td><?php echo $ResValues[3];?></td>
				</tr>	
				<tr>
					<td class="formtitle">Ciudad:&nbsp;</td>
					<td><?php echo $ResValues[4];?></td>
					<td class="formtitle">Estado:&nbsp;</td>
					<td><?php echo $ResValues[5];?></td>
				</tr>	
				<tr>
					<td class="formtitle">Tel&eacute;fono:&nbsp;</td>
					<td colspan="3"><?php echo $ResValues[6];?></td>
				</tr>	
				<tr>
					<td class="formtitle">RFC:&nbsp;</td>
					<td colspan="3"><?php echo $ResValues[1];?></td>
				</tr>				
			</table>
		</td>
	</tr>
	<tr style="width:100%">
		<td colspan="2" width="100%">
		<br>
			<table class="report" border="1" cellpadding="0" cellspacing="0" align="center" style="vertical-align:top; width:100%;">
				    <tr>
						<th>Cantidad</th>
						<th>Fecha Reservaci&oacute;n</th>
						<th>Descripci&oacute;n</th>
						<th>Costo</th>
					</tr>
				<tr>
					<td><?php echo $ResValues[12];?></td>
					<td><?php echo $ResValues[7];?></td>
					<td><?php echo $ResValues[11];?><br>Solicitud especial:<br> <?php echo $ResValues[8];?></td>
					<td><?php echo "$".$ResValues[9];?></td>
				</tr>	
				
				<tr>
					<td colspan="3" align="right">Anticipo:&nbsp;</td>
					<td><?php echo "$".($ResValues[9]-$ResValues[13]);?></td>
				</tr>
				<tr>
					<td colspan="3" align="right">Saldo:&nbsp;</td>
					<td><?php echo "$".$ResValues[13];?></td>
				</tr>
			</table>
		</td>
	</tr>
	<?php
		if(empty($imp)){
	?>
			<tr>
				<td colspan="2" align="right">
					<br>
					<input type="button" name="RegresarBtn" value="Regresar" onClick="parent.location.replace('AdminFacturas.php');" />
					<script language="javascript" type="text/javascript">
						function openFactura(id){
							var windowprops = "top=0,left=0,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=500,height=500";
							var url = "ImprimirFacturas_HTML.php?idFact="+id+"&imprimir=t";
							ventana = window.open(""+url,"ImprimirFactura", ""+windowprops);
							ventana.print();
							ventana.close();
						}
					</script>
					<input type="button" name="ImprimirBtn" value="Imprimir" onClick="openFactura(<?php echo $idFact; ?>);" />
				</td>
			</tr>
	<?php
		}
	?>
</table>

